package cn.stazxr.utils;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author talentestors
 * @version 1.0
 * @since 2025.11.03
 **/
@Component
public class WebUtils {
	public static HttpServletRequest getCurrentRequest() {
		RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
		if (attrs instanceof ServletRequestAttributes requestAttributes) {
			return requestAttributes.getRequest();
		}
		return null;
	}
}
